import { TerminologyType } from "@/mdesign-lib/mdesign-app.umd.js";
import { ProjectSpecification } from "@/mdesign-lib/mdesign-app.umd.js";
import { MetaclassType } from "@/mdesign-lib/mdesign-app.umd.js";

export type Dependency = {
  profileName: string;
  profileVersion: number;
  profileVersionId?: number;
  dependencyPath?: string;
  dependencyId?: string;
  isEffective?: boolean;
};

export type MenuItemSpec = {
  metaclass: MetaclassType;
  appliedStereotypes?: string[];
};

export type AboutVersion = {
  title: string;
  fontSize: string;
  hideVersion?: boolean;
};

export type StereotypeConfig = {
  stId: string;
  popmenu?: Record<string, string[]>;
};

export type AttrTips = {
  [key: string]: {
    title: string;
    icon: string;
    text: string;
  };
};

export interface CreateProjectItem {
  id: number;
  name: string;
  attrTipType: string;
  projectSpecification: ProjectSpecification;
  standard: string;
  icon: string;
  templatePath?: string;
  modifyModels?: boolean;
  customizationProfiles?: Dependency[];
  excludeProfiles?: Dependency[];
}

export type CustomTheme = {
  introduction: {
    title: string;
    image: string;
    imageWidth?: string;
    contentPaddingR: string;
  };
  createProject?: CreateProjectItem[];
  recentProjects: {
    class: string;

    title: string;
  };
  windowBar: {
    img: string;
    title?: string;
    hideVersionTypeName?: boolean;
  };
  launch: {
    img: string;
    top?: string;
    left?: string;
    title?: string;
    height?: number;
    imageHeight?: number;
    hideTitle?: boolean;
    hideCopyright?: boolean;
    copyright?: {
      zh: string;
      en: string;
    };
  };
  login: {
    img: string;
  };
  videoCourseList: {
    img: string;
    path?: string;
  };
  industryCaseList: {
    img: string;
  };
  about: {
    img: string;
    imgHeight?: number;
    support?: string;
    text?: string;
    version?: AboutVersion;
  };
  newGraph: {
    img: string;
  };
  fixedVersionTypeName?: string;
  cowork?: {
    loginTitle: string;
  };
  rootStyle?: {
    [name: string]: any;
  };
  userManual?: string;
};

export type HideCoworkMenu = {
  hideFunction: boolean;
};

interface ProductCaseItem {
  name: string;
  type: string;
  path: string;
  fileName: string;
  img: string;
  describe: string;
  size?: number;
}

// 定制化系统配置
export type CustomSystemConfig = {
  /**
   * 创建元素菜单配置
   **/
  cteateElementMenu?: {
    visibleItems?: MenuItemSpec[]; // 要显示的菜单项，如果不配置就是全部显示
    hideItems?: MenuItemSpec[]; // 要隐藏的菜单项，如果不配置就是都不隐藏 hideItems优先级高于visibleItems
  };
  /**
   * 创建图表菜单配置
   **/
  createDiagramMenu?: {
    visibleItems: MenuItemSpec[];
    hideItems?: MenuItemSpec[];
  };

  /**
   * 配置图形的菜单
   */
  shapeContextMenu?: {
    [key: string]: string[];
  };

  /**
   * 全局隐藏图形菜单
   */
  hideShapeContextMenu?: string[];

  /**
   * 是否隐藏cowork入口，若隐藏则登录，功能全部不可用
   **/
  hideCowork?: boolean;

  /**
   * 隐藏cowork部分功能配置
   */
  hideCoworkMenu?: HideCoworkMenu;

  /**
   * 是否隐藏画布情景菜单
   **/
  hidePopMenu?: boolean;

  checkVersion?: boolean;

  /**
   * 主题  图片，logo等
   **/
  theme: CustomTheme;
  /**
   * 是否启用统一登录
   **/
  useUnifiedLogin?: boolean;

  attrTips?: AttrTips;

  /**
   * 定制的itemflow的stereotype，创建时自动设置传递项，能编辑传递和传递项，key是stereotypeId,value.conveyId是conveys属性自动设置的值,disabled是控制能否编辑传递和传递项
   **/
  itemflowConfig?: Record<string, { conveyItemIds: string[]; disabled: boolean }>;

  // 部分表格创建需要弹窗指引
  tableCreateWizardSts?: string[];

  // 部分甘特图创建需要弹窗指引
  ganttCreateWizardSts?: string[];

  // 忽略license，忽略licesne时将无需激活可直接使用
  ignoreLicense?: boolean;

  /**
   * 是否隐藏模型库
   */
  hideModelLibrary?: boolean;

  /**
   * 是否隐藏扩展库
   */
  hideProfileLibrary?: boolean;

  /**
   * 隐藏 演示项目
   */
  hideProductCase?: boolean;

  /**
   * 隐藏 使用教程
   */
  hideVideoCourse?: boolean;

  /**
   * 隐藏 关于产品
   */
  hideIntroduction?: boolean;

  /**
   * 是否隐藏 单机license
   */
  hideSeatLicense?: boolean;

  /**
   * 是否隐藏 版本介绍
   */
  hideVersionIntroduction?: boolean;

  /**
   * 是否隐藏 CSM转换
   */
  hideCSMTransform?: boolean;

  /**
   * 是否隐藏 导出xmi
   */
  hideExportXmi?: boolean;

  // hide

  stereotypeConfigs?: Record<string, StereotypeConfig>;

  coworkPlatformName?: string; // 对应的协同平台，如果协同平台不一致则不能登录

  /**
   * 样式项目列表
   */
  demoList?: { coverd: boolean; data: ProductCaseItem[] };
  otherProduct?: {
    img: string;
    title: string;
    desc: string;
    content: string;
  }[];
  videoCourseList?: [];
  customizationProfiles?: Dependency[];
  addCustomizationImageLib?: boolean;
  MDoc?: {
    title?: string;
  };
  website?: string;
  /**
   * EWX集成
   */
  EWX?: boolean;
  /**
   * 凌云集成
   */
  LY?: boolean;

  // 智元研究院集成
  "ChinaSouth-ZY"?: boolean;
  /**
   * 科工三院集成
   */
  FHJS?: boolean;
  /**
   * 航天工程研究所18室集成
   */
  hgs18?: boolean;

  is201?: boolean;

  showJumpToCowork?: boolean;
  showJumpToRequire?: boolean;
  /**
   * 启动参数
   */
  startParams?: string[];

  terminology?: TerminologyType;
};
